package com.aaa.ssm.service.impl;


import com.aaa.ssm.dao.RegistrationDao;
import com.aaa.ssm.entity.Registration;
import com.aaa.ssm.entity.SysCareer;
import com.aaa.ssm.service.RegistrationService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjz
 * 2023/10/19
 */
@Service
public class RegistrationServiceImpl  implements RegistrationService {

    @Resource
    private RegistrationDao registrationDao;

    //@Resource
    //private RegistrationService registrationService;

    @Override
    public int updateBy(Registration registration) {
        return registrationDao.updateBy(registration);
    }

    @Override
    public Registration add(Registration registration) {
        registrationDao.add(registration);

        update(registration.getCareerId(),registration.getDate());
        return registration;
    }

    @Override
    public int update(String careerId, String date) {
        return registrationDao.update(careerId,date);
    }

    @Override
    public List<Registration> queryByParam(Registration registration) {
        return registrationDao.queryByParam(registration);
    }

    @Override
    public int delete(String id) {
        return registrationDao.delete(id);
    }

    @Override
    public PageInfo queryByPage(Page<Registration> page) {
        //设值分页参数   startPage(int pageNum, int pageSize)  pageNum 第几页  pageSize 页面
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(registrationDao.queryByParam(page.getData()));
    }

    @Override
    public List<Registration> queryByIn(String sname, String card) {
        Registration registration=new Registration();
        registration.setCard(card);
        registration.setSname(sname);
        System.out.println(registration+"+++++++++++++++++++++++++++++++++++++++++++++++++++++++============");
        List<Registration> userList=registrationDao.queryByIn(registration);
    /*    if (userList!=null&&userList.size()>0){

        }*/
        return userList;
    }


    @Override
    public int updateId(String id) {
        return registrationDao.updateId(id);
    }

    @Override
    public List<SysCareer> queryTreeDataByUserName(String name) {
        return registrationDao.queryTreeDataByUserName(name);
    }
}
